package com.liyang.springcloud.controller;

import com.liyang.springcloud.domain.CommonResult;
import com.liyang.springcloud.domain.Order;
import com.liyang.springcloud.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @BelongsProject: cloud-2024
 * @BelongsPackage: com.liyang.springcloud.controller
 * @Author: liyang
 * @CreateTime: 2024-01-10  10:05
 * @Description: 订单controller
 * @Version: 1.0
 */
@RestController
@Slf4j
@RequestMapping("/order")
public class OrderController {

    @Resource
    private OrderService orderService;

    /**
     * @description: 下订单
     * @author: liyang
     * @date: 2024/1/10 10:09
     * @param: order 订单信息
     * @return: com.liyang.springcloud.domain.CommonResult
     **/
    @PostMapping("/create")
    public CommonResult create(@RequestBody Order order) {
        orderService.create(order);
        return new CommonResult<>(200, "创建订单成功", order);
    }
}
